/*
 * LED driver
 */
#ifndef LED_H
#define LED_H

#include "dev_prv.h"

#define LED_BRIGHTNESS_MAX      255
#define LED_STATUS_ON           1
#define LED_STATUS_OFF          0

enum 
{
    kLED_breath_mode_0 = 0,
    kLED_breath_mode_1 = 1,
    kLED_breath_mode_2 = 2,
};

typedef struct _led_t
{
    void *bus_handle;
    general_out_bus_t *bus;
    
    uint16_t brightness:8;
    uint16_t status :1;
    uint16_t breath_dir :1;
    uint16_t breath_mode:2;
    uint16_t reverse:1;
    uint16_t :3;
    uint16_t breath_cnt;
    uint16_t breath_period;

}led_t;

extern void led_init(led_t *t, uint8_t brightness, uint8_t reverse, uint32_t clk);
extern void led_on(led_t *t);
extern void led_off(led_t *t);
extern void led_adjust(led_t *t, uint8_t brightness);
extern void led_breath_set(led_t *t, uint8_t mode, uint16_t period);
extern void led_breath(led_t *t, uint16_t tick);
extern void led_set_freq(led_t *led, uint16_t freq);

#endif /* LED_IO_H */
